app.controller('TemplateModalCtrl', function ($scope, $modalInstance, param, authorities) {
	$scope.submitting = false;
	$scope.param = param;
	if (!$scope.param.data) $scope.param.data = {};
	$scope.noAuth = !authorities.hasAuthority('SYSTEM_NOTIFY_ITEM_UPDATE');

	$scope.ok = function () {
		if ($scope.myForm.$valid) {
			$scope.submitting = true;
			if ($scope.noAuth) {
				$modalInstance.dismiss('cancel');
			} else {
				$modalInstance.close($scope.param);
			}
			$scope.submitting = false;
		}
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
		$scope.submitting = false;
	};
});